/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.sunspotworld.demo;

import javax.swing.*;
import java.awt.*;
import java.awt.geom.*;


/**
 *
 * @author shahsant
 */
public class Draw extends JPanel {

    private int xCord;
    private int yCord;
    BasicStroke wideStroke,fineStroke;
    GradientPaint gradient;
    private JScrollPane canvesPane;
//    private Canvas canves;

    // constructor for Draw
    public Draw(){
        //canvesPane = pane;
        //canves = new Canvas();
        Container con = new Container();
       // pane.add(con);
        //con.add(canves);
        setVisible(true);
        System.out.println("Draw Created");
        repaint();
        
    }

    public void drawLineXY(int x, int y){
        System.out.println("drawLineXY called");
        xCord = x;
        yCord = y;
        System.out.println("xCord = "+xCord+ "yCord = "+yCord);
        repaint();
    }
  

  public void paintComponents(Graphics g){
      Graphics2D g2D = (Graphics2D) g;
      g2D.setColor(Color.red);
      drawLine(g2D, xCord, yCord);
      System.out.println("X coord "+xCord+" Y Coord" + yCord);
  }


 
    public void GCanvas() {
        gradient = new GradientPaint(30, 50, Color.blue, 100, 100, Color.red, true);
        wideStroke = new BasicStroke(2);
        fineStroke = new BasicStroke(1);

    }

//    public void paint(Graphics g){
//       Graphics2D g2D = (Graphics2D) g;
//       g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
//       g2D.setStroke(wideStroke);
//       g2D.setColor(Color.red);
//       drawLine(g2D, xCord, yCord);
//       g2D.setStroke(wideStroke);
//       g2D.setPaint(gradient);
//       fillRect(g2D, 30, 50, 300, 100);
       //drawEllipse(g2D, 30, 50, 300, 100);
       //drawArc(g2D, 30, 250, 300, 100, 0, 45, Arc2D.CHORD);
//       System.out.println("X coord "+xCord+" Y Coord" + yCord);
//    }

    public void drawLine(Graphics2D g2D, int x1, int y1){

        Line2D.Float line1 = new Line2D.Float(x1, y1, x1+50, y1+50);
        Line2D.Float line2 = new Line2D.Float(x1, y1, x1-50, y1-50);
        g2D.draw(line1);
        g2D.draw(line2);

    }

    public void fillRect(Graphics g2D, int x1, int y1, int x2, int y2){
        Rectangle2D.Float rect1 = new Rectangle2D.Float(x1, y1, x2, y2);
        g2D.fillRect(x1,y1,x2,y2);
    }

    public void drawArc(Graphics2D g2D, int x1, int y1, int x2, int y2, int sd, int rd, int cl){
        Arc2D.Float arc1 = new Arc2D.Float(x1, y1, x2, y2, sd, rd, cl);
        g2D.fill(arc1);
    }

    public void drawEllipse(Graphics g2D, int x1, int y1, int x2, int y2){
        Ellipse2D.Float oval1 = new Ellipse2D.Float(x1, y1, x2, y2);
        g2D.fillOval(x1, y1, x2, y2);
    }
 
}

